(function() {
    angular.module('app').component('newProductControllerComponent', {
        templateUrl: 'app/controllers/newProduct.controller/new.product.controller.component/new.product.controller.component.html',
        controller: newProductControllerComponent,
        controllerAs: 'vm'
    });

    newProductControllerComponent.$inject = ['productBasicService', 'newControllerComponentService', '$scope', '$loading', "$timeout", '$controller', 'util'];

    function newProductControllerComponent(productBasicService, newControllerComponentService, $scope, $loading, $timeout, $controller, util) {

        var vm = this;

        vm.table = {
            count: [],
            products: []
        };


        vm.$onInit = function() {
            angular.extend(vm, $controller('commonCtrl', { $scope: $scope }));

            console.log(vm);

            //设置分页函数实现
            vm.pager.pagerChange = pagerChange;

            pagerChange();
        };


        function pagerChange() {

            console.log('----------------------newProductControllerComponent----------------------');
            $loading.start('newProdListTable');

            //angular.extend(vm.param,vm.pager);
            vm.param = util.extend(vm.param, vm.pager);

            vm.table.products.length = 0;

            newControllerComponentService.get(vm.param).then(function(data) {

                vm.pager.setAllPageCount(data.count);

                vm.table.count = data.count;

                vm.table.products = data.products;

                productBasicService.shopBasicInit();

                //monitorShopCurIndex = -1; //店铺详情的序号

                $loading.finish('newProdListTable');

                // console.log('vm.filter');
                // console.log(vm.filter)

            }, function(err) {

                $loading.finish('newProdListTable');

            });

        }

        vm.getShopBasic = productBasicService.getShopBasic; //function

    }
})();
